package com.zlc.sykks.controller;

import com.zlc.sykks.entity.LoginFormDTO;
import com.zlc.sykks.entity.User;
import com.zlc.sykks.mapper.UserMapper;
import com.zlc.sykks.result.Result;
import com.zlc.sykks.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /*
    * 登录功能
    * */
    @PostMapping("/login")
    public Result Login(@RequestBody LoginFormDTO loginFormDTO){
        log.info("用户登录:{}",loginFormDTO.getName());
        return userService.login(loginFormDTO);
    }

    /*
    * 注册功能
    * */
    @PostMapping("/register")
    public Result register(@RequestBody User user){
        log.info("用户注册:{}",user);
        return userService.register(user);
    }

    /*
    * 签到功能
    * */
    @PostMapping("/sign")
    public Result sign(){
        log.info("用户签到");
        return userService.sign();
    }

    /*
    * 获取用户连续签到次数
    * */
    @GetMapping("/getSignCount")
    public Result getSignCount(){
        return userService.getSignCount();
    }

}
